package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.BlackListMapper;
import com.tanhua.model.domain.BlackList;
import com.tanhua.model.domain.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi{
    @Autowired
    private BlackListMapper blackListMapper;

    @Override
    public IPage<UserInfo> findByUserId(Long userId, int page, int size) {
        Page pages=new Page(page,size);
        IPage<UserInfo> blackList = blackListMapper.findBlackList(pages, userId);
        return blackList;
    }

    @Override
    public void delete(Long userId, Long blackUserId) {
        LambdaQueryWrapper<BlackList> lqw=new LambdaQueryWrapper<>();
        lqw.eq(blackUserId!=null, BlackList::getBlackUserId,blackUserId);
        lqw.eq(userId!=null,BlackList::getUserId,userId);
        blackListMapper.delete(lqw);

    }
}
